﻿
@{
    ViewBag.Title = "Index";
    string UserName = ViewBag.UserName;
    string PassWord = ViewBag.PassWord;
}
<script src="~/Scripts/jquery-1.10.2.js"></script>
<h2>Index</h2>
<input type="text" id="userName" value="@UserName" />
<br />
<input type="text" id="passWord" value="@PassWord" />
<br />
<input type="button" id="btn" value="登陆" onclick="login()" />
<script>
    function login() {
        var userName = $("#userName").val();
        var passWord = $("#passWord").val();
        $.ajax({
            url: "/login/login",
            type: "post",
            data: {
                userName: userName,
                passWord: passWord
            },
            success: function (data) {
                if (data == "OK") {
                    //var _frm = document.createElement("iframe");
                    //_frm.style.display = "none";
                    //_frm.src = "http://www.FileUploada.com/cookie/setcookie?userName=" + userName + "&passWord=" + passWord;
                    //document.body.appendChild(_frm);
                    //_frm.src = "http://www.FileUploadb.com/cookie/setcookie?userName=" + userName + "&passWord=" + passWord;
                    //_frm.src = "http://www.FileUploadc.com/cookie/setcookie?userName=" + userName + "&passWord=" + passWord;
                    //--上面这种写法，在谷歌中 a 里面可以正确的写入 cookie
                    //在ie中 c 里面可以正确的写入 cookie
                    var _frm = document.createElement("iframe");
                    _frm.style.display = "none";
                    _frm.src = "http://www.FileUploada.com/cookie/setcookie?userName=" + userName + "&passWord=" + passWord;
                    document.body.appendChild(_frm);

                    alert(data);
                } else {
                    alert("错误");
                }
            }
        })
    }

</script>